package com.android.presenter.info;

import com.android.model.entity.res.SymbolListResult;
import com.android.model.net.HttpObserver;
import com.android.presenter.base.BasePresenter;
import com.android.presenter.iview.ISymbolListView;
import com.android.model.info.UserModel;
import com.android.util.log.LogUtil;

import java.util.List;

/**
 * author:  TenFace
 * date:    2017/9/27
 * description: 查询股票列表
 */

public class SymbolInfoPresenter extends BasePresenter<ISymbolListView> {

    private static final String TAG = SymbolInfoPresenter.class.getSimpleName();
    private UserModel mUserModel;

    public SymbolInfoPresenter(ISymbolListView iSymbolListView) {
        super(iSymbolListView);
        mUserModel = UserModel.getInstance();
    }

    public void getSymbolList() {
        mUserModel.getSymbolList(new HttpObserver<List<SymbolListResult>>() {
            @Override
            public void onSuccess(List<SymbolListResult> symbolListResultList) {
                LogUtil.e(TAG, "查询成功！");
                if (mIView != null) {
                    mIView.getSymbolListSuccess(symbolListResultList);
                }
            }

            @Override
            public void onError(int errType, String errMessage) {
                LogUtil.e(TAG, "失败码：" + errType + "》》信息：" + errMessage);
                if (mIView != null) {
                    mIView.getSymbolListFail(errType, errMessage);
                }
            }
        }, mIView.getLifeSubject());
    }

}
